import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
    {
        path: '/',
        name: 'HomePage',
        component: () => import("@/views/HomePage.vue"), // 默认根路径加载 HomePage.vue
    },
    {
        path: '/movie/:vid',
        name: 'MovieDetail',
        component: () => import("@/views/MovieDetail.vue"),
        props: true
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import("@/views/Login.vue"),
    },
    {
        path: '/feedback',
        name: 'Feedback',
        component: () => import("@/views/Feedback.vue"),
    },
    {
        path: '/collection',
        name: 'collection',
        component: () => import("@/views/Collections.vue"),
    },
    {
        path: '/personal',
        name:'personal',
        component: () => import("@/views/Personal.vue"),
        children: [
            {
                path: 'myCollection',
                name: 'myCollection',
                component: () => import("@/views/Collections.vue"),
            },
            {
                path: 'personalData',
                name: 'personalData',
                component: () => import("@/views/PersonalData.vue"),
            },
            {
                path: 'myComment',
                name: 'myComment',
                component: () => import("@/views/MyComment.vue"),
            },
        ]
    },
    {
        path: '/main',
        name: 'main',
        component: () => import("@/views/Main.vue"),
        redirect: "/main/MovieManage", // 子路由的重定向
        children: [
            {
                path: 'MovieManage',
                name: 'MovieManage',
                component: () => import("@/views/MovieManage.vue"),
            },
            {
                path: 'UserManage',
                name: 'UserManage',
                component: () => import("@/views/UserManage.vue"),
            },
            {
                path: 'CommentManage',
                name: 'CommentManage',
                component: () => import("@/views/CommentManage.vue"),
            },
            {
                path: 'FeedbackManage',
                name: 'FeedbackManage',
                component: () => import("@/views/FeedbackManage.vue"),
            },
        ]
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

export default router;
